<?php

namespace App\Http\Controllers\Feishu\Event;

use App\Http\Controllers\BaseController;
use App\Service\Feishu\Event\EventService;
use Illuminate\Http\Request;

class EventController extends BaseController
{
    /**
     * @return \Illuminate\Http\JsonResponse
     */
    public function receiveEvent(Request $request): \Illuminate\Http\JsonResponse
    {
        $event = new EventService();
        $event->analyseRequest($request);
        $result = $event->handle();
        return $this->json($result ?: []);
    }
}